﻿@model IEnumerable<ServiceLayer.BlogServices.BlogListDto>


<h2>Blogs</h2>

@if (TempData["message"] != null)
{
    <div class="text-success">@TempData["message"]</div><br />
}
@if (TempData["errorMessage"] != null)
{
    <div class="text-danger"><strong>@TempData["errorMessage"]</strong></div>
}

<p>
    Below you will see a table of Blogs which can be manipulated, and analysed. 
</p>
<p>
    The point of this page is to provide a simple demonstration of calling a business method - click the Analyse link to trigger this.
</p>
<hr />
<div>
    <span>@Html.ActionLink("Create New Blogger", "Create") | @Html.ActionLink("Posts", "Index", "Posts")</span>
    @*<span class="pull-right"><strong>@Html.ActionLink("Explanation of the code", "CodeView")</strong></span>*@
</div>

<table class="table">
    <tr>
        <th>
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.EmailAddress)
        </th>
        <th>
            Num Posts this Author
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.HiddenFor(modelItem => item.BlogId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.EmailAddress)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PostsCount)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.BlogId }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.BlogId }) |
            @Html.ActionLink("List Posts", "Index", "Posts", new { id = item.BlogId }, null)
        </td>
    </tr>
}

</table>
